package com.toppitch.site.data;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.toppitch.site.db.IGetFromResultSet;

public class Pitch extends BaseData implements IGetFromResultSet {
	private String pitchId;
	private String companyTicker;
	private String companyName;
	private String currentPrice;
	private String targetPrice;
	private String assetClass;
	private String geography;
	private String recommendation;
	private String country;
	private String expectedTimeframe;
	private String situation;
	private String sector;
	private String ideaAvailability;
	private String thesisId;
	private String variantViewId;
	private String modelId;
	private String modelType;
	private String modelFileName;
	private String description;
	private String authorEmail;
	private String authorFullName;
	private long posttime;
	private int commentCount;
	// not stored in database
	private boolean authorAvailable;

	public void getFromResultSet(ResultSet rs) throws SQLException {
		pitchId = rs.getString("pitchId");
		companyTicker = rs.getString("companyTicker");
		companyName = rs.getString("companyName");
		currentPrice = rs.getString("currentPrice");
		targetPrice = rs.getString("targetPrice");
		assetClass = rs.getString("assetClass");
		geography = rs.getString("geography");
		recommendation = rs.getString("recommendation");
		country = rs.getString("country");
		expectedTimeframe = rs.getString("expectedTimeframe");
		situation = rs.getString("situation");
		sector = rs.getString("sector");
		ideaAvailability = rs.getString("ideaAvailability");
		thesisId = rs.getString("thesisId");
		variantViewId = rs.getString("variantViewId");
		modelId = rs.getString("modelId");
		modelType = rs.getString("modelType");
		modelFileName = rs.getString("modelFileName");
		description = rs.getString("description");
		authorEmail = rs.getString("authorEmail");
		authorFullName = rs.getString("authorFullName");
		posttime = rs.getLong("posttime");
		commentCount = rs.getInt("commentCount");
	}

	public String toInsertString() {
		return toInsertString("pitch", pitchId, companyTicker, companyName,
				currentPrice, targetPrice, assetClass, geography,
				recommendation, country, expectedTimeframe, situation, sector,
				ideaAvailability, thesisId, variantViewId, modelId, modelType,
				modelFileName, description, authorEmail, authorFullName,
				posttime, commentCount);
	}

	public String getCompanyTicker() {
		return companyTicker;
	}

	public void setCompanyTicker(String companyTicker) {
		this.companyTicker = companyTicker;
	}

	public String getCompanyName() {
		return companyName;
	}

	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}

	public String getCurrentPrice() {
		return currentPrice;
	}

	public void setCurrentPrice(String currentPrice) {
		this.currentPrice = currentPrice;
	}

	public String getTargetPrice() {
		return targetPrice;
	}

	public void setTargetPrice(String targetPrice) {
		this.targetPrice = targetPrice;
	}

	public String getAssetClass() {
		return assetClass;
	}

	public void setAssetClass(String assetClass) {
		this.assetClass = assetClass;
	}

	public String getGeography() {
		return geography;
	}

	public void setGeography(String geography) {
		this.geography = geography;
	}

	public String getRecommendation() {
		return recommendation;
	}

	public void setRecommendation(String recommendation) {
		this.recommendation = recommendation;
	}

	public String getCountry() {
		return country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public String getExpectedTimeframe() {
		return expectedTimeframe;
	}

	public void setExpectedTimeframe(String expectedTimeframe) {
		this.expectedTimeframe = expectedTimeframe;
	}

	public String getSituation() {
		return situation;
	}

	public void setSituation(String situation) {
		this.situation = situation;
	}

	public String getSector() {
		return sector;
	}

	public void setSector(String sector) {
		this.sector = sector;
	}

	public String getIdeaAvailability() {
		return ideaAvailability;
	}

	public void setIdeaAvailability(String ideaAvailability) {
		this.ideaAvailability = ideaAvailability;
	}

	public String getThesisId() {
		return thesisId;
	}

	public void setThesisId(String thesisId) {
		this.thesisId = thesisId;
	}

	public String getVariantViewId() {
		return variantViewId;
	}

	public void setVariantViewId(String variantViewId) {
		this.variantViewId = variantViewId;
	}

	public String getModelId() {
		return modelId;
	}

	public void setModelId(String modelId) {
		this.modelId = modelId;
	}

	public String getModelType() {
		return modelType;
	}

	public void setModelType(String modelType) {
		this.modelType = modelType;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public long getPosttime() {
		return posttime;
	}

	public void setPosttime(long posttime) {
		this.posttime = posttime;
	}

	public int getCommentCount() {
		return commentCount;
	}

	public void setCommentCount(int commentCount) {
		this.commentCount = commentCount;
	}

	public String getPitchId() {
		return pitchId;
	}

	public void setPitchId(String pitchId) {
		this.pitchId = pitchId;
	}

	public String getAuthorEmail() {
		return authorEmail;
	}

	public void setAuthorEmail(String authorEmail) {
		this.authorEmail = authorEmail;
	}

	public String getDate() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		return sdf.format(new Date(posttime));
	}

	public String getAuthorFullName() {
		return authorFullName;
	}

	public void setAuthorFullName(String authorFullName) {
		this.authorFullName = authorFullName;
	}

	public String getModelFileName() {
		return modelFileName;
	}

	public void setModelFileName(String modelFileName) {
		this.modelFileName = modelFileName;
	}

	public boolean isModelUploaded() {
		return null != modelId && null != modelFileName && !"".equals(modelId)
				&& !"".equals(modelFileName);
	}

	public boolean isAuthorAvailable() {
		return authorAvailable;
	}

	public void setAuthorAvailable(boolean authorAvailable) {
		this.authorAvailable = authorAvailable;
	}
}
